#pragma once

#include "Drawer.h"
#include "BlittingFunction.h"

namespace TrueText {

class FontImpl;

class TextDrawer : public Drawer
{
public:
	TextDrawer(boost::shared_ptr<FontImpl> font)
		: font(font)
		, cacheLayout(0)
		, blendMode(BLEND_OVERWRITE)
	{ }
public:
	virtual Rectangle GetBounds(const TextLayout& layout);
	virtual boost::shared_ptr<BitmapLayer> Draw(const TextLayout& layout);

	void SetBlendMode(BlendMode value) { this->blendMode = value; }
private:
	boost::shared_ptr<BitmapLayer> DoDraw(const TextLayout& layout);

	boost::shared_ptr<FontImpl> font;
	const TextLayout* cacheLayout;
	Rectangle cacheBounds;
	boost::shared_ptr<BitmapLayer> cacheLayer;
	BlendMode blendMode;
};

}